package com.ruoyi.yuyuan.Utils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author: kestrel
 * @Version:1.0
 * @Date: 2024/6/12
 */
@WritingConverter
public class LocalDateTimeConverter implements Converter<LocalDateTime, String>{
    @Override
    public String convert(LocalDateTime localDateTime) {
        // 根据需要定义日期时间格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return localDateTime.format(formatter);
    }
}
